class Solution {//leetcode495——提莫攻击
public:
    int findPoisonedDuration(vector<int>& timeSeries, int duration) {
        int n=timeSeries.size();
        int ret=0;
        for(int i=0;i<n;i++){
            if(i+1<n){
                int x=timeSeries[i+1]-timeSeries[i];
                if(x>=duration) ret+=duration;
                else ret+=x;
            }
            else ret+=duration;
        }
        return ret;
    }
};